<?php
class rates extends MY_Model{
        public function __construct() {
            parent::__construct();
        }
     //insert rates
    public function add_rate($fields=array()){   
        if(empty($fields)){
            return false;
        }
        $this->db->insert('rates',$fields);
        return $this->db->insert_id();
    }
    
    //get rates by product id
    public function get_rate($pro_id){
        $this->db->where('product_id',$pro_id);
        $query = $this->db->get('rates');
        return $query->result();
    }
    
    //update rate
    public function update_rate($fields=array(),$rate_id=false)
    {
        if($rate_id){
            $this->db->where('rate_id',$rate_id);
            $this->db->update('rates',$fields);
            return true;
        }
        return false;
    }
    
    //delete rate
    public function delete_rate($rate_id=false){
        if($rate_id){
            $this->db->where('rate_id',$rate_id);
            $this->db->delete('rates');
            return true;
        }
        return false;
    }       
}
?>